|
|
|
|
|
|
|
You see, the computer doesn't care what you do with those bits. It doesn't know what they mean. Giving meaning to those bits is the programmer's job. Visual Basic variables do this for you most of the time. API and DLL calls often don't. That's one of the reasons that you need to know what's going on behind the scenes. |
|
|
|
|
|
|
|
|
Now let's say that you have four bits. Four bits are a nibble. Let's say that those bits each have a label indicating their position in the nibble, from Bit #0 to Bit #3. The possible values are as follows: |
|
|
|
|
| BIT #3 | BIT #2 | BIT #1 | BIT #0 | VALUE | | 0 | 0 | 0 | 0 | 0 | | 0 | 0 | 0 | 1 | 1 | | 0 | 0 | 1 | 0 | 2 | | 0 | 0 | 1 | 1 | 3 | | 0 | 1 | 0 | 0 | 4 | | 0 | 1 | 0 | 1 | 5 | | 0 | 1 | 1 | 0 | 6 | | 0 | 1 | 1 | 1 | 7 | | 1 | 0 | 0 | 0 | 8 | | 1 | 0 | 0 | 1 | 9 | | 1 | 0 | 1 | 0 | 10 | | 1 | 0 | 1 | 1 | 11 | | 1 | 1 | 0 | 0 | 12 | | 1 | 1 | 0 | 1 | 13 | | 1 | 1 | 1 | 0 | 14 | | 1 | 1 | 1 | 1 | 15 |
|
|
|
|
|
|
Now we're getting somewhere. A nibble lets you count up to 16 values, in this case from 0 to 15. Are other values possible? What happens if we say that Bit #3 indicates whether a number is negative? |
|
|
|
|
| BIT #3 | BIT #2 | BIT #1 | BIT #0 | VALUE | | 0 | 0 | 0 | 0 | 0 | | 0 | 0 | 0 | 1 | 1 | | 0 | 0 | 1 | 0 | 2 | | 0 | 0 | 1 | 1 | 3 | | 0 | 1 | 0 | 0 | 4 | | 0 | 1 | 0 | 1 | 5 | | 0 | 1 | 1 | 0 | 6 | | 0 | 1 | 1 | 1 | 7 | | 1 | 0 | 0 | 0 | 8 | | 1 | 0 | 0 | 1 | 7 |
|
|
|
|
|
|
(table continued on next page) |
|
|
|
|
|